package com.app.biz.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.app.common.annotation.Log;
import com.app.common.core.controller.BaseController;
import com.app.common.core.domain.AjaxResult;
import com.app.common.core.page.TableDataInfo;
import com.app.common.enums.BusinessType;
import com.app.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.app.biz.domain.BizAppDataManageField;
import com.app.biz.service.IBizAppDataManageFieldService;


/**
 * 数据质量管理字段Controller
 * 
 * @author ruoyi
 * @date 2024-09-09
 */
@RestController
@RequestMapping("/system/field")
public class BizAppDataManageFieldController extends BaseController
{
    @Autowired
    private IBizAppDataManageFieldService bizAppDataManageFieldService;

    /**
     * 查询数据质量管理字段列表
     */
    //@PreAuthorize("@ss.hasPermi('system:field:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizAppDataManageField bizAppDataManageField)
    {
        startPage();
        List<BizAppDataManageField> list = bizAppDataManageFieldService.selectBizAppDataManageFieldList(bizAppDataManageField);
        return getDataTable(list);
    }

    /**
     * 导出数据质量管理字段列表
     */
    //@PreAuthorize("@ss.hasPermi('system:field:export')")
    @Log(title = "数据质量管理字段", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizAppDataManageField bizAppDataManageField)
    {
        List<BizAppDataManageField> list = bizAppDataManageFieldService.selectBizAppDataManageFieldList(bizAppDataManageField);
        ExcelUtil<BizAppDataManageField> util = new ExcelUtil<BizAppDataManageField>(BizAppDataManageField.class);
        util.exportExcel(response, list, "数据质量管理字段数据");
    }

    /**
     * 获取数据质量管理字段详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:field:query')")
    @GetMapping(value = "/{baseId}")
    public AjaxResult getInfo(@PathVariable("baseId") String baseId)
    {
        return success(bizAppDataManageFieldService.selectBizAppDataManageFieldByBaseId(baseId));
    }

    /**
     * 新增数据质量管理字段
     */
    //@PreAuthorize("@ss.hasPermi('system:field:add')")
    @Log(title = "数据质量管理字段", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizAppDataManageField bizAppDataManageField)
    {
        return toAjax(bizAppDataManageFieldService.insertBizAppDataManageField(bizAppDataManageField));
    }

    /**
     * 修改数据质量管理字段
     */
    //@PreAuthorize("@ss.hasPermi('system:field:edit')")
    @Log(title = "数据质量管理字段", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizAppDataManageField bizAppDataManageField)
    {
        return toAjax(bizAppDataManageFieldService.updateBizAppDataManageField(bizAppDataManageField));
    }

    /**
     * 删除数据质量管理字段
     */
    //@PreAuthorize("@ss.hasPermi('system:field:remove')")
    @Log(title = "数据质量管理字段", businessType = BusinessType.DELETE)
	@DeleteMapping("/{baseIds}")
    public AjaxResult remove(@PathVariable String[] baseIds)
    {
        return toAjax(bizAppDataManageFieldService.deleteBizAppDataManageFieldByBaseIds(baseIds));
    }

    //@PreAuthorize("@ss.hasPermi('system:field:list')")
    @GetMapping("/listRecent")
    public AjaxResult listRecent(BizAppDataManageField bizAppDataManageField)
    {

        List<BizAppDataManageField> list = bizAppDataManageFieldService.selectBizAppDataManageFieldListRecent(bizAppDataManageField);
        return success(list);
    }
}
